home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dr. Windows 3
/
dr win3.zip
/
dr win3
/
PROGRAMR
/
GSRC208A.ZIP
/
GEP1.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-07-07
|
18KB
|
621 lines
#include "copyleft.h"
/*
GEPASI - a simulator of metabolic pathways and other dynamical systems
Copyright (C) 1989, 1992 Pedro Mendes
*/
/*************************************/
/* */
/* GWTOP - Topology */
/* MS-WINDOWS front end */
/* */
/* Initialization and some */
/* data structures */
/* */
/* QuickC/WIN 1.0 */
/* */
/* (include here compilers that */
/* compiled GWSIM successfully) */
/* */
/*************************************/
#include <windows.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <io.h>
#include <sys\types.h>
#include <sys\stat.h>
#include "globals.h"
#include "topgvar.h"
#include "strtbl.h"
#include "gwtop.h"
#include "iotop.h"
struct kint {
unsigned char nsub;
unsigned char npro;
unsigned char nmodf;
unsigned char revers;
int idx;
LPSTR descr;
};
struct nodet{
char item;
unsigned char val;
unsigned char left;
unsigned char right;
} ;
struct treet{
struct nodet node[256];
char id[64][10];
float constant[32];
int nnode,
nnum,
nid,
nsub,
npro,
nmodf,
nconst,
revers;
char descr[64];
} ;
GLOBALHANDLE hMetname; /* handle to memory block w/ metname */
GLOBALHANDLE hStepname; /* handle to memory block w/ stepname */
GLOBALHANDLE hStoiu; /* handle to memory block w/ stoiu */
GLOBALHANDLE hLoop; /* handle to memory block w/ loop */
GLOBALHANDLE hKtype; /* handle to memory block w/ ktype */
GLOBALHANDLE hRstr; /* handle to memory block w/ rstr */
GLOBALHANDLE hTree; /* handle to memory block w/ tree */
char (huge *metname)[NAME_L]; /* pointer to work with metname array */
char (huge *stepname)[NAME_L]; /* metabolite names */
int huge *stoiu; /* pointer to work with metname array */
unsigned char (huge *loop)[MAX_STEP][MAX_MET]; /* def. of modification loops */
int (huge *rstr)[MAX_STEP][MAX_MOL]; /* reaction structure */
char topname[256]; /* title for the topology */
double xu[MAX_MET]; /* concentrations at time t user */
int intmet[MAX_MET]; /* 1 if internal metabolite */
unsigned char revers[MAX_STEP]; /* 1 if reaction is reversible */
int kinetu[MAX_STEP]; /* type of kinetics (user numb.) */
int kfl[MAX_STEP]; /* flags for input of user-def.kinetics */
unsigned char nmod[MAX_STEP]; /* number of assigned modfs of a react. */
struct kint huge *ktype; /* ptr array of kinetic types & proprt */
double endtime; /* time value for last iteration */
double hrcz; /* highest rate considered zero */
double dft_endtime; /* time value for last iteration */
double dft_hrcz; /* highest rate considered zero */
float ver_no; /* .top and .sim version number */
int totmet; /* number of total metabolites */
int nmetab; /* number of internal metabolites */
int nsteps; /* number of steps */
int nloops; /* number of modifier loops */
int nrateq; /* number of kinetic types in the datab */
int newtree; /* 1 if user added kinetic new types */
int nudf; /* number of user-defined kin. types */
int debugval; /* debug mode */
int dft_debugval; /* debug mode */
int options; /* various options */
struct treet huge *tree; /* function tree for rate equations */
struct treet tr; /* tree for the input */
/* Initialization of GEPASI's variables */
int InitGepasiVar( void )
{
int i, j;
hMetname = GlobalAlloc( GMEM_MOVEABLE | GMEM_ZEROINIT, (DWORD) MAX_MET * NAME_L * sizeof( char ) );
if( hMetname == NULL ) return -1;
hStepname = GlobalAlloc( GMEM_MOVEABLE | GMEM_ZEROINIT, (DWORD) MAX_STEP * NAME_L * sizeof( char ) );
if( hStepname == NULL )
{
GlobalFree( hMetname );
return -1;
}
hStoiu = GlobalAlloc( GMEM_MOVEABLE | GMEM_ZEROINIT, (DWORD) MAX_MET * MAX_STEP * sizeof( int ) );
if( hStoiu == NULL )
{
GlobalFree( hMetname );
GlobalFree( hStepname );
return -1;
}
hLoop = GlobalAlloc( GMEM_MOVEABLE | GMEM_ZEROINIT, (DWORD) MAX_STEP * MAX_MET * sizeof( unsigned char ) );
if( hLoop == NULL )
{
GlobalFree( hMetname );
GlobalFree( hStepname );
GlobalFree( hStoiu );
return -1;
}
hKtype = GlobalAlloc( GMEM_MOVEABLE | GMEM_ZEROINIT, (DWORD) MAX_TYP * sizeof( struct kint ) );
if( hKtype == NULL )
{
GlobalFree( hMetname );
GlobalFree( hStepname );
GlobalFree( hStoiu );
GlobalFree( hLoop );
return -1;
}
hRstr = GlobalAlloc( GMEM_MOVEABLE | GMEM_ZEROINIT, (DWORD) MAX_MOL * MAX_STEP * sizeof( int ) );
if( hRstr == NULL )
{
GlobalFree( hMetname );
GlobalFree( hStepname );
GlobalFree( hStoiu );
GlobalFree( hLoop );
GlobalFree( hKtype );
return -1;
}
nudf = 0;
hTree = GlobalAlloc( GMEM_MOVEABLE | GMEM_ZEROINIT, (DWORD) sizeof( struct treet ) );
if( hTree == NULL )
{
GlobalFree( hMetname );
GlobalFree( hStepname );
GlobalFree( hStoiu );
GlobalFree( hLoop );
GlobalFree( hKtype );
GlobalFree( hRstr );
return -1;
}
metname = ( char (huge *)[NAME_L] ) GlobalLock( hMetname );
stepname = ( char (huge *)[NAME_L] ) GlobalLock( hStepname );
stoiu = ( int huge * ) GlobalLock( hStoiu );
loop = ( unsigned char (huge *)[MAX_STEP][MAX_MET] ) GlobalLock( hLoop );
ktype = ( struct kint huge * ) GlobalLock( hKtype );
rstr = ( int (huge *)[MAX_STEP][MAX_MOL] ) GlobalLock( hRstr );
tree = ( struct treet huge * ) GlobalLock( hTree );
newtree = 0;
for( i=0; i<MAX_MET; i++ ) intmet[i] = 1; /* set all metb. to be internal */
totmet = nmetab = nsteps = 0; /* clear no. of metb. and steps */
nrateq = MAX_TYP; /* set the no. of kinetic types */
ktype[NOT].nsub = 0; /* init info of kinetic types */
ktype[NOT].npro = 0;
ktype[NOT].revers = -1;
ktype[NOT].nmodf = 0;
ktype[NOT].descr = (LPSTR) "<not defined>";
ktype[I01].nsub = 0;
ktype[I01].npro = 0;
ktype[I01].revers = 0;
ktype[I01].nmodf = 0;
ktype[I01].descr = (LPSTR) "constant rate";
ktype[I10].nsub = 20;
ktype[I10].npro = 20;
ktype[I10].revers = 0;
ktype[I10].nmodf = 0;
ktype[I10].descr = (LPSTR) "no type";
ktype[I11].nsub = 1;
ktype[I11].npro = 1;
ktype[I11].revers = 0;
ktype[I11].nmodf = 0;
ktype[I11].descr = (LPSTR) "mass action";
ktype[R11].nsub = 1;
ktype[R11].npro = 1;
ktype[R11].revers = 1;
ktype[R11].nmodf = 0;
ktype[R11].descr = (LPSTR) ktype[I11].descr;
ktype[I21].nsub = 2;
ktype[I21].npro = 1;
ktype[I21].revers = 0;
ktype[I21].nmodf = 0;
ktype[I21].descr = (LPSTR) ktype[I11].descr;
ktype[R21].nsub = 2;
ktype[R21].npro = 1;
ktype[R21].revers = 1;
ktype[R21].nmodf = 0;
ktype[R21].descr = (LPSTR) ktype[I11].descr;
ktype[I12].nsub = 1;
ktype[I12].npro = 2;
ktype[I12].revers = 0;
ktype[I12].nmodf = 0;
ktype[I12].descr = (LPSTR) ktype[I11].descr;
ktype[R12].nsub = 1;
ktype[R12].npro = 2;
ktype[R12].revers = 1;
ktype[R12].nmodf = 0;
ktype[R12].descr = (LPSTR) ktype[I11].descr;
ktype[I31].nsub = 3;
ktype[I31].npro = 1;
ktype[I31].revers = 0;
ktype[I31].nmodf = 0;
ktype[I31].descr = (LPSTR) ktype[I11].descr;
ktype[R31].nsub = 3;
ktype[R31].npro = 1;
ktype[R31].revers = 1;
ktype[R31].nmodf = 0;
ktype[R31].descr = (LPSTR) ktype[I11].descr;
ktype[I13].nsub = 1;
ktype[I13].npro = 3;
ktype[I13].revers = 0;
ktype[I13].nmodf = 0;
ktype[I13].descr = (LPSTR) ktype[I